package org.rexsong.example.quartzsample.jobs.simple;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.rexsong.example.quartzsample.utils.JobWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
@Component
public class SimpleJob extends QuartzJobBean {

    private SimpleJobTask simpleJobTask;

    @Autowired
    public SimpleJob(SimpleJobTask simpleJobTask) {
        this.simpleJobTask = simpleJobTask;
    }

    @Override
    public void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobWrapper.run(jobExecutionContext, () -> simpleJobTask.runJob());
    }
}
